package org.lc.cmd.connect.impl;

import org.lc.cmd.connect.ClientSession;
import org.lc.cmd.connect.ReconnectStrategy;
import org.lc.cmd.connect.model.CloseInfo;

public class DefaultReconnectStrategy implements ReconnectStrategy {
    @Override
    public long onRetry(ClientSession session, CloseInfo closeInfo, int retryTimes) {
        if (retryTimes > 3) {
            return -1;
        }
        showReconnecting(session, closeInfo, retryTimes);
        return (long) Math.pow(2, retryTimes + 1) * 1000;
    }

    @Override
    public void onReconnected(ClientSession session) {
        showReconnected(session);
    }

    protected void showReconnecting(ClientSession session, CloseInfo closeInfo, int retryTimes) {
        // todo
    }

    protected void showReconnected(ClientSession session) {
        // todo
    }
}
